import 'dart:io';

import 'package:flutter/material.dart';

void main() {
  runApp(new WrapPlugin());
}

/*
 * 流式布局、自动换行  Wrap是一个可以使子控件自动换行的控件，默认的方向是水平的  <br/>
 * 需要传入的键：<br/>
 * 传入的值类型： <br/>
 * 传入的值含义：<br/>
 * 是否必传 ：
 */
class WrapPlugin extends StatefulWidget {
  State<StatefulWidget> createState() {
    return new WrapPluginState();
  }
}

/*
 * 页面功能 <br/>
 */
class WrapPluginState extends State<StatefulWidget> {
  List<String> tags = [
    "肯德基",
    "小哥哥你的东西掉了",
    "小姐姐好漂亮啊",
    "这个东西是啥",
    "哈哈哈",
    "好困啊",
    "今天好运",
    "明天好运来",
    "今年快结束了",
    "我累啊",
    "你写的什么代码",
    "多多多"
  ];

  void initState() {
    super.initState();
  }

  Widget build(BuildContext context) {
    AppBar appBar = AppBar(
      leading: new IconButton(
        icon: new Icon(Icons.arrow_back),
        onPressed: () {},
      ),
      title: new Text('FlutterDesign'),
      centerTitle: true,
      actions: <Widget>[
        new Container(width: 0, height: 0),
        new Container(width: 0, height: 0),
      ],
      backgroundColor: Colors.blue,
    );

    return MaterialApp(
      home: new Scaffold(
        appBar: appBar,
        body: new Builder(builder: (BuildContext context) {
          return Wrap(
            children: create(),
          );
        }),
        backgroundColor: Colors.white,
        bottomNavigationBar: null,
      ),
    );
  }

  List<Widget> create() {
    List<Widget> result = [];
    for (String item in tags) {
      result.add(Container(
        margin: EdgeInsets.all(8),
        child: Text(item),
      ));
    }
    return result;
  }
}
